﻿#ifndef _DB_IFEATURE_H
#define _DB_IFEATURE_H

#include "geometry/interface/igeometry.h"
#include "geometry/interface/ienvelope.h"
#include "udatabase/interface/ifield.h"
#include "udatabase/interface/ifields.h"
#include "kernel/Referenced.h"
#include "udatabase/dll_cfg.h"

namespace FD
{
	namespace Utility
	{
		namespace DB
		{
			namespace Interface
			{
				/// <summary>
				/// 要素类接口
				/// </summary>
				class FD_DB_Export IFeature : public FD::Kernel::CReferenced
				{
				public:	
					/// <summary>
					/// 默认析构函数
					/// </summary>
					virtual ~IFeature();
				public:
					/// <summary>
					/// 获取要素ID
					/// </summary>
					/// <returns>ID号，一般情况下，大于0</returns>
					virtual UINT32 getID() const;
					/// <summary>
					/// 获取要素的几何体类型
					/// </summary>
					/// <returns>几何体类型枚举</returns>
					virtual FD::Kernel::Geometry::Interface::GeometryType getGeometryType() const;
					/// <summary>
					/// 获取要素字段集合
					/// </summary>
					/// <returns>字段集合，内部引用，外部无需释放</returns>
					virtual const FD::Utility::DB::Interface::IFields* getFieldsRef() const;
					/// <summary>
					/// 获取要素字段数目
					/// </summary>
					/// <returns>字段数目</returns>
					virtual UINT32 getFieldCount() const;
					/// <summary>
					/// 获取指定索引的要素字段
					/// </summary>
					/// <param name="index">指定索引</param>
					/// <returns>字段对象，内部引用，外部无需释放</returns>
					virtual const FD::Utility::DB::Interface::IField* getFieldRef(UINT32 index) const;
					/// <summary>
					/// 找到指定字段名称的字段
					/// </summary>
					/// <param name="fieldName">字段名称</param>
					/// <returns>如果找到，返回该索引，如果没有找到，返回-1</returns>
					virtual INT32 findField(const String& fieldName) const;
					/// <summary>
					/// 获取指定索引的字段值
					/// </summary>
					/// <param name="value">输出，字段值</param>
					/// <param name="index">指定索引</param>
					/// <returns></returns>
					virtual void getValue( FD::Kernel::Variant & value,UINT32 index) const;
					virtual void getValue( FD::Kernel::Variant& value, const String& name) const;
					/// <summary>
					/// 获取要素的几何体对象
					/// </summary>
					/// <returns>内部引用，外部无需释放</returns>
					virtual const FD::Kernel::Geometry::Interface::IGeometry * getGeometryRef() const;
					/// <summary>
					/// 获取要素的外包围盒
					/// </summary>
					/// <returns>内部引用，外部无需释放</returns>
					virtual const FD::Kernel::Geometry::Interface::IEnvelope* getEnvelopeRef() const;
					/// <summary>
					/// 设置要素的几何体对象，内部拷贝该几何体
					/// </summary>
					/// <param name="geom">几何体对象</param>
					/// <returns></returns>
					virtual void setGeometry(const FD::Kernel::Geometry::Interface::IGeometry * geom);

					/// <summary>
					/// 设置指定索引的字段值
					/// </summary>
					/// <param name="value">字段值</param>
					/// <param name="index">指定索引</param>
					/// <returns></returns>
					virtual void setValue(const FD::Kernel::Variant & value,UINT32 index);

					/// <summary>
					/// 在数据集上删除要素
					/// </summary>
					/// <returns>true，成功；false，失败</returns>
					virtual bool deleteFeature();
					/// <summary>
					/// 在数据集上保存要素
					/// </summary>
					/// <returns>true，成功；false，失败</returns>
					virtual bool saveFeature();
					/// <summary>
					/// 克隆要素
					/// </summary>
					/// <returns>返回克隆的要素，外部释放</returns>
					virtual  FD::Utility::DB::Interface::IFeature * clone() const;

				protected:
					/// <summary>
					/// 默认构造函数
					/// </summary>
					IFeature();
				private:
					/// <summary>
					/// 拷贝构造函数
					/// </summary>
					C_DISABLE_COPY(IFeature);
				};
			}
		}
	}
}

#endif
